package com.cy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.StringRedisTemplate;

@SpringBootApplication
public class RedisApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(RedisApplication.class, args);
    }

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //注意改配置---1.要把linux中的redis配置文件redis.conf中的只允许本地端口访问redis,给注释掉(#bind 127.0.0.1 -::1)
    //   2.把redis.conf中的保护模式改为no--"protected-mode no"
    @Override
    //springboot项目启动时会调用CommandLineRunner对象的run方法
    public void run(String... args) throws Exception {
        System.out.println("Stringredistemplate=" + stringRedisTemplate);
        //String name=stringRedisTemplate.opsForValue().get("name");
        // System.out.println("name="+name);
    }
}
